#include <iostream>
using namespace std;

class Rect {
public:
	static int n;

	Rect();
	Rect(int, int);
	~Rect();

	void set(int, int);
	int area(void);
	int getX(void);
	int getY(void);

	Rect* operator+(Rect);

	friend Rect* duplicate(Rect&);

private:
	int x, y;
};

Rect::Rect()
{
	x = 0;
	y = 0;
}

Rect::Rect(int x_, int y_)
{
	x = x_;
	y = y_;
}

Rect::~Rect()
{
}

void Rect::set(int x_, int y_)
{
	x = x_;
	y = y_;
}

int Rect::area(void)
{
	return x * y;
}

int Rect::getX(void)
{
	return x;
}

int Rect::getY(void)
{	
	return y;
}

Rect* Rect::operator+(Rect r)
{	
	Rect *temp = new Rect;
	temp->set(x + r.getX(), y + r.getY());
	return temp;
}

Rect* duplicate(Rect &rect)
{
	Rect *temp = new Rect;
	temp->x = rect.x;
	temp->y = rect.y;
	return temp;
}

int Rect::n = 6;

int main(void)
{
	Rect a, b(3, 4), *c, *d, *e, *f, *g;
	
	a.set(1, 2);
	c = new Rect(5, 6);
	d = &a;
	e = new Rect[2];
	e[0].set(7, 8);

	f = a + b;

	cout << "a area: " << a.area() << endl;
	cout << "b area: " << b.area() << endl;
	cout << "c area: " << c->area() << endl;
	cout << "c area: " << (*c).area() << endl;
	cout << "d area: " << d->area() << endl;
	cout << "e[0] area: " << e[0].area() << endl;
	cout << "e[1] area: " << e[1].area() << endl;
	cout << "f area: " << f->area() << endl;

	cout << "a n: " << a.n << endl;
	a.n++;
	cout << "c n: " << c->n << endl;

	g = duplicate(*f);
	cout << "g area: " << g->area() << endl;

	delete c;
	delete[] e;
	delete f;
	delete g;
	
	return 0;
}
